<template>
	<view class="content">
		<view class="grace-idcard-items">
			
			<view class="grace-idcard-uper-btn2" >
				<view class="">
					<img style="height: auto !important;padding-top: 4rem;" class="w50 pT30" src="../../static/img/renlian.jpg" mode=""></img>
				</view>
			</view>
			<view class=" tCenter" style="font-size: 16px;">认证通过</view>
			<view class="tips-text tCenter f14">感谢您对实人认证的信任与支持</view>
			<view class="backdiv pT20" @click="addCustomer">
				<view class="back">
					确定
				</view>
			</view>
		</view>

		
	</view>
</template>
<script>
var _self;
import mInput from '../../components/m-input.vue';
import {userfaceveif,userinfo} from '@/common/api/user.js'

export default {
	components: {
		mInput
	},
	data() {
		return {
			account: '',
			password: '',
			repassword: '',
			email: '',
			captchaImg: '',
			message_code: '',
			seconds: 60,
			codeBtn: {
				text: '获取验证码',
				waitingCode: false,
				count: this.seconds
			},
			idCard1: '',
			idCard2: '../../static/imgs/idcard2.png',
			code: '',
			shenfenx: '',
			namex: '',
			xingbie: '',
			dizhi: '',
			checkoperatorchanger:false,
			gourl:'/pages/shouquan/conpany',
			showtype:'',
		};
	},
	// onLoad: function(option) {
	// 	_self = this;
	// 	console.log(option.id); //打印出上个页面传递的参数。
	// 	console.log(option.name); //打印出上个页面传递的参数。
	// },

	onLoad(event) {
		_self = this;
		// 目前在某些平台参数会被主动 decode，暂时这样处理。
		if(event.type){
			this.showtype=event.type
		}
	},

	methods: {
		addCustomer(){			
			var thisurl = sessionStorage.getItem("locationhref");
			if (thisurl) {
				if(thisurl=='pages/shouquan/shengfen'){
					uni.reLaunch({
						url:'/pages/yaoqing/useraddvisitors'
					  });
				}else{
					var newhrf = "/" + thisurl;
						sessionStorage.setItem("locationhref",'');
						sessionStorage.setItem("skippage",'') 
					
					uni.reLaunch({
					    url: newhrf
					});
				}
				
			    
			}else{
				if(this.showtype=='yuyue'){
					uni.reLaunch({
						url:'/pages/yaoqing/useraddvisitors'
					  });
				}else{
					uni.reLaunch({
						url:'/pages/myyuyue/myyuyue?type=1'
					  });
				}
			}
			
			
		},
		showuserinfo(){
			userinfo({}).then(res=>{//获取用户信息
				console.log(res)				
				uni.setStorageSync('userid', res.data.data.id);
				uni.setStorage({
				    key: 'headimgurl',
				
				    data: res.data.headimgurl
				});
				uni.setStorageSync('username', res.data.data.name);
				uni.setStorage({
				    key: 'isIdentitycard',
				    data: res.data.data.identitycard
				});
				uni.setStorage({
				    key: 'userInfo',
				    data: res.data
				});
				sessionStorage.setItem("tokensession",res.data.data.openid);
				
			})
		},
		register: function(){
			uni.navigateTo({
				// url: '/pages/shouquan/yingye'
				url: '/pages/subject/problem'
			});
			console.log(1)
			return
		},
		selectImg1(){
			// uni.chooseImage({
			//   	count: 1,
			//   	 sourceType: ['camera'], //从相册选择
			//   	success: res => {
			// 		console.log(res)
			// 	},
			// 	})	
					userfaceveif({
						name: this.banner.name,
						sex: this.banner.sex,
						address: this.banner.address,
						identitycard: this.banner.identitycard,
						src: this.banner.imgurl,
						imgurl_b:this.banner.imgurl_b,
						idcard_date_type:this.banner.idcard_date_type,
						idcard_date_begin:this.banner.idcard_date_begin,
						idcard_date_end:this.banner.idcard_date_end,
						birth:this.banner.birth,
						type:this.banner.type,
						ca:this.banner.issuance,
						issuance:this.banner.issuance
						
					}).then(res=>{
						// console.log(JSON.parse(res.data))
						 
						var requestresult = JSON.parse(res.data)

						if (requestresult.code == 200) {
							uni.hideLoading();
							// uni.showToast({
							// 	title: requestresult.message,
							// 	icon: 'none',
							// 	duration: 2000
							// });
							// uni.reLaunch({
							// 	url:this.gourl
							// });
							 sessionStorage.setItem("tokensession",'YES');
							this.showuserinfo()
							uni.showModal({
							    title: '',
							    content: '认证通过',
							    success: function (res) {
							        if (res.confirm) {
							         
							          var thisurl = sessionStorage.getItem("locationhref");
							          if (thisurl) {
							              var newhrf = "/" + thisurl;
							          		sessionStorage.setItem("locationhref",'');
							          		sessionStorage.setItem("skippage",'') 
							          
							              uni.reLaunch({
							                  url: newhrf
							              });
							          }else{
							          	uni.reLaunch({
							          		url:'/pages/shouquan/successful?type=yuyue'
							          	});
							          }
									  
									  
									  
									  
							        } else if (res.cancel) {
							            console.log('用户点击取消');
							        }
							    }
							});
							
							
							
							
							
						} else if (requestresult.code == 400) {
							uni.hideLoading();
							uni.showToast({
								title: requestresult.message,
								icon: 'none',
								duration: 2000
							});
						}
					})
		},

		gotoLogin: function() {
			uni.navigateTo({
				url: 'login'
			});
		},
		checkoperator(e){
			if(this.checkoperatorchanger){
				this.checkoperatorchanger = false
				this.gourl = '/pages/shouquan/conpany'
			}else{
				this.checkoperatorchanger = true
				this.gourl = '/pages/shouquan/yingye'
			}
			
			
		}
	},
	computed: {
		disableCodeBtn: function() {
			return this.codeBtn.waitingCode || this.captchaImg.length < 11;
		}
	}
};
</script>
<style>
.cvc {
	line-height: 40px;
}
.content {
	display: flex;
	flex: 1;
	flex-direction: column;
	background-color: #ffffff;
}
.sb {
	font-size: 15px;
	width: 104px;
	margin-right: 10px;
	margin-top: 5px;
	margin-bottom: 5px;
}

img {
	height: 400upx !important;
}

view {
	font-size: 28upx;
}
.tips {
	width: 81px;
	height: 25px;
	color: rgba(42, 130, 228, 1);
	font-size: 17px;
	margin: 0 auto;
	margin-top: 10px;
}
.tips-text {
	/* width: 248px; */
	height: 24px;
	margin: 0px auto 0;
	color: #000;
	font-size: 15px;
}
.admin-text {
	color: rgba(80, 80, 80, 1);
	font-size: 13px;
	margin: 0 auto;
}
.admin-tips {
	color: rgba(80, 80, 80, 1);
	font-size: 14px;
	margin: 0 auto;
}
.register {
	width: 192px;
	height: 42px;
	position: absolute;
	left: 25%;
	bottom: 10%;
	text-align: center;
	color: rgba(255, 255, 255, 1);
	background-color: rgba(42, 130, 228, 1);
	border-radius: 18px;
	font-size: 15px;
	line-height: 42px;
}
.grace-idcard-main {
	margin: 20upx 30upx;
}
.btn-plusempty{
		width: 110upx;
		height: 110upx;
		background: #007bfa;
		position: fixed;
		bottom: 50upx;
		right: 20upx;
		border-radius: 100%;
		overflow: hidden;
		text-align: center;
		line-height: 110upx;
	}
.grace-idcard-desc {
	line-height: 2em;
	background: #ffffff;
	padding: 20upx;
	border-radius: 10upx;
}

.grace-idcard-text {
	line-height: 2em;
	margin-top: 30upx;
}

.grace-idcard-items {
	background: #ffffff;
	padding: 30upx 0;
	/* display: flex; */
	/* margin: 30upx 0; */
	border-radius: 10upx;
	align-items: flex-start;
}

.grace-idcard-uper-btn {
	width: 195px;
	height: 195px;
	margin: 0 auto;
	background-color: rgba(255, 255, 255, 1);
	padding-bottom: 10upx;
	border-radius: 98px;
	font-size: 15px;
	text-align: center;
	border: rgba(128, 128, 128, 1) solid 1px;
}
.grace-idcard-uper-btn2 {
	width: 195px;
	margin: 0 auto;
	background-color: rgba(255, 255, 255, 1);
	padding-bottom: 10upx;
	border-radius: 98px;
	font-size: 15px;
	text-align: center;
}
.grace-idcard-uper-btn2 .img {
	width: 400upx;
	height: 400upx;
	margin: 0 auto;
	border-radius: 50%;
	overflow: hidden;
}

.grace-idcard-uper-btn2 .img image {
	width: 400upx;
	height: 400upx !important;
}

.grace-idcard-uper-btn .img {
	width: 400upx;
	height: 400upx;
	margin: 0 auto;
	border-radius: 50%;
	overflow: hidden;
}

.grace-idcard-uper-btn .img image {
	width: 400upx;
	height: 400upx !important;
}

.grace-idcard-uper-btn .text {
	width: 100%;
	margin-top: 50upx;
	text-align: center;
	line-height: 2em;
}

.grace-idcard-preview {
	width: 50%;
	margin: 0 30upx;
}

.grace-idcard-preview image {
	width: 100%;
	height: 400upx !important;
}
.backdiv .back{width: 70%;margin: 0 auto;  text-align:center;border: 1px solid #8e8e8e;border-radius: 80px;line-height: 35px;}
</style>
